package licode.unisop.authcenter.adapter.web;

import licode.unisop.client.api.auth.SopUserAuthQuery;
import licode.unisop.client.info.SopTokenInfo;
import licode.unisop.client.utils.SopRequestParse;
import licode.unisop.unilite.result.UniReturnResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * 定义统一认证平台中心认证相关接口
 *
 * @author licode
 */
@Slf4j
@UniReturnResult
@RestController
@RequestMapping("/uni-center/v1/auth")
public class CenterAuthController {
    @Resource
    private HttpServletRequest request;

    @Resource
    private SopUserAuthQuery sopUserAuthQuery;

    @RequestMapping(value = "/user/assets", method = RequestMethod.POST)
    public Map<String, Object> getUserAssets() {
        SopTokenInfo tokenInfo = SopRequestParse.getAccessTokenInfo(request);
        return sopUserAuthQuery.getUserAssets(tokenInfo);
    }
}
